import type { EditorComps, OptionProps, TextProps, ValueStatusArr } from '@/types'
import { isPicTitleDescStatusArr, isStringStatusArr, isValueStatusArr } from '@/types'
import { ActiveViews, EditorType, MaterialComDesType } from '@/constants'

// 导出文字
export const getTextStatus = (props: TextProps) => {
  return props.status;
}

// 根据当前下标获取数据
export const getPicTitleDescStatusArr = (props: OptionProps) => {
  if(props && isStringStatusArr(props.status)){
    return props.status[props.currentStatus];
  }
}

// 获取字符串数组
export const getStringStatus = (props: OptionProps)=>{
  if(props && isStringStatusArr(props.status)){
    return props.status;
  }
}

export const getPicStatusArr = (props: OptionProps) => {
  if(props && isPicTitleDescStatusArr(props.status)){
    return props.status;
  }
}

export const getValueStatusArr = (props: OptionProps)=>{
  if (props && isValueStatusArr(props.status)){
    return props.status[props.currentStatus];
  }
}

// 获取当前选中的
export const getCurrentStatus = (props: OptionProps) => {
  return props?.currentStatus;
}

export const setActiveViews = (key: string, value: ActiveViews) => {
  localStorage.setItem(key, value);
}

export const updateInitStatusBeforeAdd = (editorComData: EditorComps,MaterialComType: MaterialComDesType)=>{
  switch (MaterialComType){
    case MaterialComDesType.PersonalPhoneNumber:{
      editorComData.status[EditorType.title].status = '请输入手机号码';
      break;
    }
    case MaterialComDesType.PersonalAddress:{
      editorComData.status[EditorType.title].status = '请输入地址';
      break;
    }
    case MaterialComDesType.PersonalEmail:{
      editorComData.status[EditorType.title].status = '请输入邮箱地址';
      break;
    }
    case MaterialComDesType.PersonalQQ:{
      editorComData.status[EditorType.title].status = '请输入QQ号码';
      break;
    }
    case MaterialComDesType.PersonalWechat:{
      editorComData.status[EditorType.title].status = '请输入微信号码';
      break;
    }
  }
}
